<template>
  <a-drawer width="576" :title="formTitle" :label-col="4" :wrapper-col="14" :visible="open" :body-style="{ height: 'calc(100vh - 100px)', overflow: 'auto' }" @close="cancel">
    <a-form-model ref="form" :model="form" :rules="rules" layout="vertical">
      <a-spin :spinning="spinning" :delay="delayTime" tip="Loading...">
        <a-row :gutter="32">
          <a-col :span="24">
            <a-form-model-item label="地区名称" prop="name">
              <a-input v-model="form.name" placeholder="请输入地区名称" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="地区编码" prop="code">
              <a-input v-model="form.code" placeholder="请输入地区编码" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="地区简称" prop="abbreviation">
              <a-input v-model="form.abbreviation" placeholder="请输入地区简称" />
            </a-form-model-item>
          </a-col>

          <a-col :span="12">
            <a-form-model-item label="地区类型" prop="type">
              <a-select
                placeholder="请选择地区类型"
                v-model="form.type"
                :getPopupContainer="
                  triggerNode => {
                    return triggerNode.parentNode || document.body
                  }
                "
                style="width: 100%"
                allow-clear
              >
                <a-select-option v-for="(d, index) in typeOptions" :key="index" :value="d.dictValue">{{ d.dictLabel }}</a-select-option>
              </a-select>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="地区省份" prop="province">
              <select-area type="select" :level="0" v-model="form.province" placeholder="请选择地区省份" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="运营者" prop="userId" v-hasPermi="['platform:region:add']">
              <select-user v-model="form.userId" select-model="single" placeholder="请选择运营者" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="关联部门" prop="departId" v-hasPermi="['platform:region:add']">
              <select-dept v-if="deptDisabled" v-model="form.departId" select-model="single" select-scope="all" placeholder="请选择关联部门" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="是否私有" prop="isPrivate">
              <a-select
                placeholder="请选择私有类型"
                v-model="form.isPrivate"
                :getPopupContainer="
                  triggerNode => {
                    return triggerNode.parentNode || document.body
                  }
                "
                style="width: 100%"
                allow-clear
              >
                <a-select-option v-for="(d, index) in isPrivateOptions" :key="index" :value="d.dictValue">{{ d.dictLabel }}</a-select-option>
              </a-select>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="地区头像" prop="avatar">
              <image-upload v-model="form.avatar" isMultiple :number="1" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="朋友圈二维码" prop="momentImage">
              <image-upload v-model="form.momentImage" isMultiple :number="1" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="公众号二维码" prop="officialAccountImage">
              <image-upload v-model="form.officialAccountImage" isMultiple :number="1" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="收款码" prop="receiveMoneyImage">
              <image-upload v-model="form.receiveMoneyImage" isMultiple :number="1" />
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-spin>
      <div class="bottom-control">
        <a-space>
          <a-button :disabled="disabled" @click="cancel"> 取消 </a-button>
          <a-button type="primary" :disabled="disabled" @click="submitForm(true)"> 保存 </a-button>
        </a-space>
      </div>
    </a-form-model>
  </a-drawer>
</template>
<script>
import RegionEditForm from './RegionForm'
export default {
  ...RegionEditForm
}
</script>
